﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Swashbuckle.AspNetCore.Annotations;
using System.Threading.Tasks;
using VisionCloud.Domain.Common;

namespace VisionSurface.Web.Controllers.Wx
{
    /// <summary>
    /// 系统设置
    /// </summary>
    [Route("api/miniapp/wx/[controller]/[Action]")]
    [ApiVersion("1.0")]
    [ApiExplorerSettings(GroupName = "微信消息推送")]
    public class SettingController : ControllerBase
    {
        private readonly IConfiguration cfg;

        public SettingController(IConfiguration cfg)
        {
            this.cfg = cfg;
        }

        /// <summary>
        /// 获取微信的订阅消息模板Id
        /// </summary>
        /// <returns></returns>
        [HttpGet, AllowAnonymous]
        [SwaggerResponse(0, "Result字段为消息模板数组")]
        public async ValueTask<ApiResult> GetTemplate()
        {
            var templates = cfg.GetSection("WxTemplateIds").Get<string[]>();
            return new ApiResult { Code = AjaxCode.Success, Result = templates };
        }
    }
}
